Skip to content

Dev - #97

Merged
erayhanoglu merged 3 commits into
mainfrom
dev
Aug 28, 2026
Merged

Dev#97
erayhanoglu merged 3 commits into
mainfrom
dev

Conversation

@erayhanoglu

Copy link
Copy Markdown
Member

No description provided.

erayhanoglu and others added 3 commits August 28, 2026 11:34
_normalizeNamedParams() previously matched ":name" anywhere inside a
token, so it corrupted string literals ('literal :notparam text') and
misread the second ":" of a "::" cast as a parameter. Reworked it to use
an anchored per-token regex (a real ":name" reference is always isolated
as its own token by the tokenizer) plus a check for the preceding token
being a lone ":", and to substitute only the matched portion so any
leading whitespace merged into a token is preserved.

Also fixes a related bug this surfaced: a named param's index was
computed before confirming it would actually be registered, so a param
with no matching value in the params object silently reused its index
for the next distinct param, corrupting both in the generated SQL.

Adds unit test coverage for all of the above plus casts on literals,
chained casts, prefix collisions between param names, SQL-order vs
object-order indexing, case sensitivity, and the params-must-be-an-object
validation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Same bug class as pg-connection: NAMED_PARAM_PATTERN matched ":name"
anywhere inside a token instead of requiring the whole token to be one,
so a string/double-quoted-identifier literal containing ":something" was
corrupted - the entire token was replaced with "@something", discarding
everything else in it.

T-SQL also has its own gap Postgres doesn't: "[bracket]" quoted
identifiers aren't a "quote" character the tokenizer recognizes, so
"[col:name]" comes back as three separate tokens ("[col", ":name", "]").
Added explicit bracket-depth tracking so a ":name" inside one is left
alone.

Adds unit test coverage for both, plus multiple/repeated params, the
no-named-param no-op case, and that the params object itself is never
rewritten (mssql binds by name via request.input(), unlike postgres's
positional rebuild).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@erayhanoglu
erayhanoglu merged commit c438f1e into main Aug 28, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant